
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <meta name="description" content="xms">
    <meta name="author" content="xms">
    <link rel="icon" href="/content/favicon.ico">

    <title>自定义 - Web资源 - 新建Web资源</title>

    <!-- Bootstrap core CSS -->
    <link href="/content/css/bootstrap3.3.5/bootstrap.min.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="/content/css/dashboard.css" rel="stylesheet">
    <link href="/content/css/font-awesome.min.css" rel="stylesheet">
    <link href="/content/customize/css/common.css" rel="stylesheet">
    <link href="/content/js/jquery-toast/jquery.toast.min.css" rel="stylesheet">
    <link id="themeLink" href="/content/css/theme/default.css" rel="stylesheet" />
    <!-- Bootstrap core JavaScript ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="/content/js/jquery.min.js"></script>
    <script src="/content/js/bootstrap.min.js"></script>
    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <script src="/content/js/ie10-viewport-bug-workaround.js"></script>
    <script src="/content/js/jquery.bootstrap.min.js"></script>
    <script src="/content/js/json2.js"></script>
    <script src="/content/js/xms.utility.js"></script>
    <script src="/content/js/jquery-ui-1.10.3/ui/jquery.ui.core.js"></script>
    <script src="/content/js/jquery-ui-1.10.3/ui/jquery.ui.widget.js"></script>
    <script src="/content/js/jquery-ui-1.10.3/ui/jquery.ui.mouse.js"></script>
    <script src="/content/js/jquery-ui-1.10.3/ui/jquery.ui.draggable.js"></script>
    <script src="/content/js/jquery-toast/jquery.toast.min.js"></script>
    <script src="/content/js/xms.jquery.js"></script>
    <script src="/content/js/xms.web.js"></script>
    <script src="/content/js/xms.metadata.js"></script>
    <script src="/content/js/md5.js" type="text/javascript"></script>
    <script src="/content/js/commonlabels.js"></script>
    <script src="/content/js/common/pagecontext.js"></script>
    <script src="/api/user/usercontext"></script>
    <script>
        jQuery(function () {
            Xms.Web.Loading();
            function aLinkClick(e) {

                if (currentKeycode != 17 && window.parent && window.parent.addToTab) {
                    e.preventDefault();
                    var tabNav = $('#customTabNav', parent.document).children('.iframe-link-linkitem.active');
                    var textEl = tabNav.clone();
                    $(".glyphicon-remove", textEl).remove();
                    var label = textEl.text();
                    textEl = $(this).clone();
                    $("span", textEl).remove();
                    label = label + '-' + textEl.text();
                    var link = $(this).attr("href");
                    var id = $.md5(link);
                    Xms.Web.callParentMethod('addToTab', { id: id, label: label, link: link });
                    return false;
                } else {
                    //  currentKeycode = -99999;
                    //  var link = $(this).attr("href");
                    //  Xms.Web.OpenWindow(link);
                }

            }
            var currentKeycode = -99999;
            $("body").on("click.customizeLinkclick", 'a[href]a:not([href^="javascript:"])a:not([href^="#"])', function (e) {
                aLinkClick.call(this, e);
            });
        });
    </script>
    <link rel="stylesheet" type="text/css" href="/content/customize/codemirror/codemirror.css" />
    <link rel="stylesheet" type="text/css" href="/content/customize/codemirror/tomorrow-night-bright.css" />
    <style>
        body {
            padding: 0;
            margin: 0;
        }

        .table-responsive {
            max-height: 400px;
            overflow-y: auto;
        }

        .panel-default .panel-heading {
            background-color: white;
        }
    </style>
</head>
<body>
<div class="" id="body">
    <div class="clearfix">
        <div class="col-md-12" id="main">
            <div class="" style="padding:5px;" id="renderBody">
                <!--main-->

                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title">
                            <a data-toggle="collapse"
                               href="#collapseTwo">
                                <strong>新建Web资源</strong>
                            </a>
                        </h3>
                    </div>
                    <div id="collapseTwo" class="panel-collapse collapse in">
                        <div class="panel-body">
                            <form action="/xms/api/webresource/create" data-jsonajax="true" data-formdata="false" method="post" id="editform" class="form-horizontal" role="form" data-autoreset="true">
                                <div class="form-group col-sm-12">
                                    <label class="col-sm-2 control-label" for="Name">名称</label>
                                    <div class="col-sm-10">
                                        <input class="form-control required" id="Name" name="Name" type="text" />
                                    </div>
                                </div>
                                <div class="form-group col-sm-12">
                                    <label class="col-sm-2 control-label" for="WebResourceType">类型</label>
                                    <div class="col-sm-10">
                                        <input class="form-control required" data-val="true" data-val-required="The WebResourceType field is required." data-value="Script" id="WebResourceType" name="WebResourceType" type="text" value="Script" />
                                    </div>
                                </div>
                                <div class="form-group col-sm-12">
                                    <label class="col-sm-2 control-label" for="Description">描述</label>
                                    <div class="col-sm-10">
                        <textarea class="form-control" id="Description" name="Description">
</textarea>
                                    </div>
                                </div>
                                <div id="type-editor" class="form-group col-sm-12 contentEditor-wrap">
                                    <label class="col-sm-2 control-label" for="Content">内容</label>
                                    <div class="col-sm-10">
                                        <div id="contentEditor" class="contentEditor"><span class="contentEditor-close glyphicon glyphicon-remove"></span><span class="contentEditor-fullscreen glyphicon glyphicon-fullscreen"></span><textarea class="form-control" id="Content" name="Content" rows="8">
</textarea></div>
                                    </div>
                                </div>

                                <div class="form-group col-sm-12 text-center" id="form-buttons">
                                    <button type="submit" class="btn btn-primary"><span class="glyphicon glyphicon-saved"></span> 保存</button>
                                    <button type="reset" class="btn btn-default"><span class="glyphicon glyphicon-refresh"></span> 重置</button>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>

            </div>
            <nav class="navbar navbar-default navbar-fixed-bottom hide" role="navigation" id="body-footer">
                <div class="container">
                    <div class="navbar-form navbar-right" id="body-footer-content">
                    </div>
                </div>
            </nav>
        </div>
    </div>
</div>

<script src="/content/js/jquery.form.js"></script>
<script src="/content/js/jquery-validate/jquery.validate.min.js"></script>
<script src="/content/js/jquery-validate/localization/messages_zh.min.js"></script>
<script src="/content/customize/codemirror/codemirror.js" type="text/javascript"></script>
<script src="/content/customize/codemirror/addon/selection/active-line.js"></script>
<script src="/content/customize/codemirror/edit/matchbrackets.js"></script>
<script src="/content/customize/codemirror/addon/hint/show-hint.js"></script>
<script src="/content/customize/codemirror/addon/hint/javascript-hint.js"></script>
<script src="/content/customize/codemirror/mode/javascript.js"></script>
<script src="/content/customize/codemirror/mode/markdown.js"></script>
<script>
    var editor;
    $(function () {
        $('#WebResourceType').picklist({
            items: [{ label: '脚本', value: '0' }, { label: '网页', value: '2' }, { label: '样式', value: '3' }]
            , required: true
        });
        //表单验证
        Xms.Web.Form($("#editform"), function (response) {
            Xms.Web.Alert(response.IsSuccess, response.Content);
            Xms.Web.Event.localStorageEvent.trigger('list_webresource_rebind');

            if (response.IsSuccess) {
                Xms.Web.Event.publish('refresh');
                editor.setValue('');
            }
        });

        $('.contentEditor-fullscreen').on('click', function () {
            $('.contentEditor-wrap').addClass('active');
        })
        $('.contentEditor-close').on('click', function () {
            $('.contentEditor-wrap').removeClass('active');
        })
        var textarea = document.getElementById('Content');
        editor = CodeMirror.fromTextArea(textarea, {
            indentWithTabs: true,
            smartIndent: true,
            lineNumbers: true,
            styleActiveLine: true,
            matchBrackets: true,
            extraKeys: {
                "Esc": function (cm) {
                    var fullScreen = cm.getOption("fullScreen");
                    cm.setOption("fullScreen", !fullScreen);
                },
                "Ctrl-Q": "autocomplete"
            }
        });
        editor.setOption("theme", "tomorrow-night-bright");
        editor.on("change", function (editor, changes) {
            $('#Content').val(editor.getValue());
        });
    });
    function fullEdit() {
        $('#contentEditor').prop('style', '');
    }
</script>

</body>
</html>